﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Data;
public partial class mendoctor_addSF : System.Web.UI.Page
{
    public OleDbConnection myConnection;
    public static readonly string sConnectionString = System.Configuration.ConfigurationManager.AppSettings["SQLConnString"].ToString();
    protected void Page_Load(object sender, EventArgs e)
    {
        myConnection = new OleDbConnection(sConnectionString);
        myConnection.Open();
        if (Session["UserName"] == null && Session["UserNo"] == null)
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>" +
                "alert('登录超时（或未登录），请您重新登录！'); parent.location.href='../login.aspx'</script>", false);

    }
    protected void ButtonOK_Click(object sender, EventArgs e)
    {
        string cfNo = UserNo.Text.Trim();
        string cfName = UserName.Text.Trim();
        string cfClass = UserClass.Text.Trim();
        string cfgg = Usergg.Text.Trim();
        string cfdj = UserPrice.Text.Trim();


        string mysql = "select * from ChargeTb where CID='" + cfNo + "'  ";
        OleDbCommand mycmd = new OleDbCommand(mysql, myConnection);
        OleDbDataReader myReader = mycmd.ExecuteReader();
        if (myReader.Read())
            LabelError.Text = "输入的编号已经存在，请重新输入！";
        else
        {
            string myinsert = "insert into ChargeTb (CID,Cname,Csp,Cun,Price) values" +
                "('" + cfNo + "','" + cfName + "','" + cfClass + "','" + cfgg + "','" + cfdj+ "')";
            mycmd = new OleDbCommand(myinsert, myConnection);
            mycmd.ExecuteScalar();
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('收费标准信息信息添加成功！');</script>", false);
            UserNo.Text = "";
            UserName.Text = "";
            UserClass.Text = "";
            Usergg.Text = "";
            UserPrice.Text = "";
            LabelError.Text = "";
        }
    }
    protected void ButtonReset_Click(object sender, EventArgs e)
    {
        UserName.Text = "";
        UserNo.Text = "";
        UserClass.Text = "";
        Usergg.Text = "";
        UserPrice.Text = "";
        LabelError.Text = "";
    }
}